/**
 * User: Ngannv
 * Date: 9/18/11
 * Email : ngankt2@gmail.com
 */
/**
 * @by ngannv 02-2011
 * @param arr
 * @param level
 */
var jLib = {
    version:"1.0.0",
    date:"30-09-2011",
    author:"Ngannv",
    conf:function() {
        var doc = document,win = window,n = navigator,ua = n.userAgent
        this.isOpera = win.opera && opera.buildNumber;
        this.isWebKit = /WebKit/.test(ua);
        this.isIE = !this.isWebKit && !this.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(n.appName);
        this.isIE6 = this.isIE && /MSIE [56]/.test(ua);
        this.isGecko = !this.isWebKit && /Gecko/.test(ua);
        this.isMac = ua.indexOf("Mac") != -1;
        this.isAir = /adobeair/i.test(ua);
        this.isChrome = ua.toLowerCase().indexOf("chrome") != -1;
        this.isFireFox = ua.toLowerCase().indexOf('firefox') != -1;
        this.isSafari = ua.toLowerCase().indexOf('safari') != -1;
    },
    printObj:function(obj, level) {
        var output = "";
        if (!level) level = 0;
        var padding = "";
        for (var j = 0; j < level + 1; j++) {
            padding += "    ";
        }
        if (typeof(obj) == 'object') {
            for (var item in obj) {
                var value = obj[item];
                if (typeof(value) == 'object') {
                    output += padding + "'<b>" + item + "'</b>=><b>{</b>\n";
                    output += jLib.printObj(value, level + 1);
                } else {
                    output += padding + "  '<b>" + item + "</b>' => \"<i>" + value + "</i>\",\n";
                }
            }
            output += padding + '<b>}</b>\n';
        } else {
            output = "===>" + obj + "<===(" + typeof(obj) + ")";
        }
        return output;
    },
    isEmail:function(email) {
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        return reg.test(email);
    }

};
window.jLib = jLib;
jLib.conf();